package net.ojbk.study.twobox.beans.select;

import net.ojbk.study.twobox.beans.vo.SelectOption;
import net.ojbk.study.twobox.dao.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: twobox
 * Date: 2019/4/18
 * Time: 21:34
 * Description: No Description
 */
@Component
public class SelectOptionUtil {
    private String[] strings = {"lesson"};

    @Autowired
    LessontypeMapper lessontypeMapper;
    @Autowired
    ClassMapper classMapper;
    @Autowired
    DepartmentMapper departmentMapper;
    @Autowired
    StaffMapper staffMapper;
    @Autowired
    PostMapper postMapper;

    public List<SelectOption> getSelectOptionListByName(String name) throws Exception{
        if (name.equals("lesson"))
            return lessontypeMapper.getAllSO_Lesson();
        else if (name.equals("class"))
            // 所有班级
            return classMapper.getAllClass();
        else if (name.equals("department"))
            return departmentMapper.getAllDepartmentName();
        else if (name.equals("staff"))
            return staffMapper.getAllStaff();
        else if (name.equals("post"))
            return postMapper.getAllPost();
        else
            throw new Exception("SelectOptionListByName：非法类型");
    }
}
